package UjicobaCitra;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.RoundRectangle2D;
import javax.swing.JFrame;
import javax.swing.JPanel;


public class Mobil extends JPanel {
    public Mobil(){
    setBackground(Color.white);
   }
    
    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.setColor(Color.BLUE);
        g.drawRect(10,30,150,80);
        g.setColor(Color.RED);
        g.drawRect(160,30,100,80);
        g.setColor(new Color(255,0,0));
        g.fillOval(10,100,30,40);
        g.setColor(new Color(255,0,0));
        g.fillOval(170,100,30,40);
        
        }

public static void main(String args[]){
        JFrame frame = new JFrame( "Grafik 2 Dimensi" );
        frame.addWindowListener( new WindowAdapter(){
            @Override
        public void windowClosing( WindowEvent e ){
        System.exit( 0 );
        }
        });
        
        frame.setLayout(new BorderLayout());
        UjicobaCitra.Mobil Mobil = new UjicobaCitra.Mobil();
        frame.add(Mobil,BorderLayout.CENTER);
        frame.setSize( 450, 250 );
        frame.setVisible(true);
        }
    }
